package com.seafwg.springboot1;

import com.seafwg.springboot1.service.SayHello;
import com.seafwg.springboot1.vo.Student;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class Springboot1Application implements CommandLineRunner {

    public static void main(String[] args) {
        // ConfigurableApplicationContext context = SpringApplication.run(Springboot1Application.class, args);
        // SayHello sayHello = (SayHello) context.getBean("sayHello");
        // sayHello.sayHello();
        SpringApplication.run(Springboot1Application.class, args);
    }

    /**
     * 注入容器，@SpringBootApplication是一个复合注解，
     * 里面包含了@Configuration注解，可作为配置类使用
     * @return
     */
    @Bean("wenbb")
    public Student createStu() {
        Student student = new Student();
        student.setId(007);
        student.setName("wenbaobao");
        student.setAge(23);

        return student;
    }


    @Override
    public void run(String... args) throws Exception {
        // 应用以启动，就执行
        System.out.println("重写run方法执行...");
    }
}
